package com.chengzhi.web.controller;

import com.chengzhi.channel.OrderChannel;
import com.chengzhi.entity.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @param
 * @author RCZ
 * @description
 * @create 2018-01-20 16:17
 */
@RestController
@EnableBinding(OrderChannel.class)
public class OrderController {

    @Autowired
    private OrderChannel orderChannel;

    @RequestMapping("sendOrder")
    public void sendOrder() {
        Order order = new Order();
        order.setOrderId("7414554445");
        order.setPayAmount(new BigDecimal("555"));
        order.setPayStatus(2);
        orderChannel.output().send(MessageBuilder.withPayload(order).build());
    }
}
